<?php

namespace plugin\jumplink\app\controller;

use support\Request;
use support\Response;
use plugin\jumplink\app\model\JumplinkList;

class IndexController
{

    public function index()
    {
        return view('index/index', ['name' => 'jumplink']);
    }

    public function reurl($link){
        
        $model = new JumplinkList;
        $l = $model->where('content',$link)->where('auth_time','>',date('Y-m-d H:i:s'))->where('status',1)->first();
      
        if($l){
           if($l->down_maxnum<=$l->down_num){
               return Response('无效链接');
           }
           $model->where('id',$l->id)->update(['down_num'=>$l->down_num+1]);
           return redirect($l->redirect_url); 
        }else{
           return Response('无效链接');
        }
    }

}
